//destribes the terrain of a game.

#ifndef UTERRAIN
#define UTERRAIN
#include "../stdafx.h"
#include <boost/multi_array.hpp>
#include <boost/shared_ptr.hpp>
#include "../UModel.h"
#include "../UVector.h"

typedef boost::multi_array<float, 2> float2darray;
typedef boost::multi_array<TVector, 2> vector2darray;


class TTerrain
{
private:
	int width, height;

	float2darray  HeightMapData;
	TVector GetNormalOfFace(int x, int y);
public:
	TTerrain(std::string TerrainName, std::string ColorMapName); 
	vector2darray HeightMapNormals;//bezetheid
	
	float HeightAtPos(int X, int Y)const; 
	TVector GetPosAtMPos(int MPX, int MPY);
	bool IsFlat(int X, int Y);
	int Width()  const {return width ;};//nr of pixels
	int Height() const {return height;};//nr of pixels
};

class TGUITerrain
{
private:
	GLuint nVBOVertices;
	GLuint nVBOTexCoords;
	GLuint nVBONormals;
	GLuint nVBOColors;
	int nVertexCount;
	void MyDraw();
	boost::shared_ptr<const TTerrain> Terrain;
	void PushVectorColor(int x, int y, std::vector<uint32>* ColArray);
public:
	TGUITerrain(TTerrainRefConst terrain);
	void Draw();
};


#endif
